﻿using System;
using System.Collections.Generic;

namespace EnterpriseFramework.DataAccess
{
    public class Where
    {
        private string _Expression = string.Empty;
        public string Expression
        {
            get { return _Expression; }
        }

        private List<Parameter> _ParamList = new List<Parameter>();
        public List<Parameter> ParamList
        {
            get { return _ParamList; }
        }

        public Where(string expression, params Parameter[] param)
        {
            _Expression = expression;
            if (param != null)
                _ParamList.AddRange(param);
        }

        public static Where operator &(Where v1, Where v2) { return v1.AND(v2); }
        public static Where operator |(Where v1, Where v2) { return v1.OR(v2); }


        public Where AND(Where v)
        {
            _Expression = _Expression + " AND " + v._Expression;
            _ParamList.AddRange(v._ParamList);
            return this;
        }
        //public Where ANDNOT(Where v) { }
        public Where OR(Where v)
        {
            _Expression = _Expression + " OR " + v._Expression;
            _ParamList.AddRange(v._ParamList);
            return this;
        }
        //public Where ORNOT(Where v) { }
    }
}
